package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Customer;
import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.service.CustomerService;
import com.atguigu.jxc.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RequestMapping("/customer")
@RestController
public class CustomerController {
    @Autowired
    private CustomerService customerService;
    /**
     * 分页查询客户
     * @param page 当前页数
     * @param rows 每页显示的记录数
     * @param customerName 客户名字
     * @return map
     */
    @PostMapping("list")
    public Map<String, Object> list(Integer page, Integer rows, String customerName) {
        Map<String, Object> map = customerService.list(page, rows, customerName);
        return map;
    }

    /**
     * 客户添加或修改
     * @param customerId
     * @param customer
     * @return ServiceVO
     */
    @PostMapping("save")
    public ServiceVO save(Integer customerId, Customer customer) {

        return customerService.save(customerId, customer);
    }

    /**
     * 批量删除客户
     * @param ids 1,4,6
     * @return
     */
    @PostMapping("delete")
    public ServiceVO delete(String ids) {
        return customerService.delete(ids);
    }
}
